<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
	<title>房间列表</title>
	<base href="<%=basePath%>"> 
	<!--[if lt IE 9]>
	<script type="text/javascript" src="js/html5.js"></script>
	<script type="text/javascript" src="js/respond.min.js"></script>
	<script type="text/javascript" src="js/PIE_IE678.js"></script>
	<![endif]-->
	<link rel="stylesheet" href="js/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
	<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
	<link rel="stylesheet" type="text/css" href="js/Hui-iconfont/1.0.7/iconfont.css" />
	<link rel="stylesheet" type="text/css" href="js/icheck/icheck.css" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
	<link rel="stylesheet" type="text/css" href="css/vivo.css" />
	
	<!--[if IE 6]>
	<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
	<script>DD_belatedPNG.fix('*');</script>
	<![endif]-->
	
	
	
	<script type="text/javascript" src="js/jquery-1.11.1.js"></script> 
	<script type="text/javascript" src="js/layer/layer/layer.js"></script> 
	<script type="text/javascript" src="js/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
 	<!-- grid.simple.min.css, grid.simple.min.js -->
	<link rel="stylesheet" href="js/grid/bsgrid.all.min.css"/>
	<script type="text/javascript" src="js/grid/grid.zh-CN.min.js"></script>
	<script type="text/javascript" src="js/grid/bsgrid.all.min.js"></script>
	<script type="text/javascript" src="js/sharefunction.js"></script>
	<script type="text/javascript" src="js/init.js"></script>
	<script type="text/javascript" src="static/h-ui/js/H-ui.js"></script> 
	<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> 
	<script language="javascript">

		var zTreeObj;
		var infoId = "";
		var pInfoId = "";
		$(document).ready(function(){
		    zTreeObj = initTree("treeDemo","project/roomInfo/treeJson");
		    zTree = $.fn.zTree.getZTreeObj("treeDemo");
		    rMenu = $("#rMenu");
		    if(infoId==""||infoId==null){
			    $("#room_btn_add").hide();
			}
			
		});
		
		//树点击前执行的方法
		function beforeClick(){
		
		}
		
		  //右键执行的方法
		function OnRightClick(event, treeId, treeNode) {
		    //treeNode.id 树的id
		    zTree.selectNode(treeNode);
		    
			//showRMenu(treeNode.id, event.clientX, event.clientY);
				
		}
		
		var level = ""
		
		function onClick(e, treeId, treeNode){
			$("#room_btn_add").hide();
			var params="&stater=1";
			var stater="1";
			level = treeNode.level;
			
			
		//	alert(treeNode.level);
			if(level==2){
				infoId = treeNode.id;
				params = "&infoId="+infoId+"&stater=1";
			}else if(level==1){
				$("#room_btn_add").hide();
				pInfoId = treeNode.id;
				params ="&pInfoId="+pInfoId+"&stater=1";
			}
			//console.log(infoId);
			gridObj.options.otherParames=params;
			gridObj.refreshPage(); 
		}

		function doSearch(treeNode){
			var params = "";
			var roomNumber = $("#roomNumber").val();
			var stater="1";
			params = "&infoId="+infoId+"&stater="+stater+"&pInfoId="+pInfoId+"&level="+level+"&roomNumber="+roomNumber;
			gridObj.options.otherParames = params;
			gridObj.refreshPage();
		}


		function openAdd(){
			var url = "project/roomInfo/toAdd/"+infoId;
			openTitleLayer("新增房间 ",url,840,450);
		}

	</script>

  </head>
  
  <body>
    <div id="main" class="main">
	    <input type="hidden" id="stater" name="stater" value="${stater }" />
	    <div id="tree" class="ztree-left">
		   <ul id="treeDemo" class="ztree"></ul>
		</div>
	
		<div id="lay-right" class="lay-right">
			<div style="padding:1px"></div>
			<div class="cl pd-5 bg-1 bk-gray" style="height: 34px;margin: 8px 19px 10px 0px;">
			房间关键字：<input type="text" name="roomNumber" id="roomNumber" size="15" placeholder="房间号关键字">
			
			&nbsp; <a class='btn btn-success radius'  onClick=doSearch()  ><span class="glyphicon glyphicon-search"></span>查 询</a>
			&nbsp; <a style="display:none" id="room_btn_add"  class='btn btn-primary radius' onClick='openAdd(this)' ><span class="glyphicon glyphicon-plus"></span>新 增</a> 
		</div>
		
	
	<table id="searchTable" width="100%">
		<tr>
			<th w_index="no" width="3%;" w_align="center">序号</th>
			<th w_index="projectName" width="10%;" w_align="center">所属楼盘</th>
			<th w_index="buildingInfoName" width="10%;" w_align="center">所属楼栋</th>
			<th w_index="roomNumber"  width="10%;" w_align="center">房间号</th>
			<th w_index="coveredArea"  width="10%;">建筑面积</th>
			<th w_index="lastDate"  width="10%;" w_align="center">装修时间</th>
			<th w_index="archiveState"  width="5%;" w_align="center">归档状态</th>
			<th w_index="datails" width="10%;" w_render="Data">操作</th>
			<th w_hidden="true" w_index="id" >id</th>
			<th w_hidden="true" w_index="typeChoice" >attId</th>
			<th w_hidden="true" w_index="addUserid" >addUserid</th>
		</tr>
	</table>
	<script type="text/javascript">
				var gridObj;
				$(function () {
					var stater=$("#stater").val();
					gridObj = $.fn.bsgrid.init('searchTable', {
						url: "project/roomInfo/getzhuangRoomInfoJsonData",
						autoLoad: true,
						pageSizeSelect: true, 
						multiSort: true ,
						displayBlankRows: false ,
						pagingLittleToolbar: true,
						stripeRows: true,
						rowHoverColor: true,
						pageSize: 15,
						otherParames:{"infoId":infoId,"stater":1},
						curPage:1
						
						
					});
				});
				//操作
				function Data(record, rowIndex, colIndex, options) {
					var html="";;
					var id = gridObj.getRecordIndexValue(record, 'id');
					var roomName=gridObj.getRecordIndexValue(record, 'roomNumber');
					
					var elementids2 = $("#sys_permissionids").val();
					
					var sys_user_id=$("#sys_user_id").val();
					var addUserid = gridObj.getRecordIndexValue(record, 'addUserid');
					var sys_userid = $("#sys_userid").val();
					
					//if(elementids2.indexOf("room_btn_details")!=-1){
						html=" <a  href=javascript:detail(this,'"+id+"','房间-"+roomName+"') data-title='"+roomName+"'>查看详情</a>";
					//} else{
					//	html = "<a style='cursor:text'>--</a>";
					//}
					if(elementids2.indexOf("room_btn_edit")!=-1 ||addUserid==sys_userid||addUserid==sys_user_id){
						html+=" &nbsp; &nbsp; <a   href=javascript:edit('"+id+"');>编辑</a>";
					}else{
						html += " &nbsp; &nbsp;<a style='cursor:text'>--</a> &nbsp; &nbsp;";
					}
					if(elementids2.indexOf("room_btn_del")!=-1 ||addUserid==sys_userid||addUserid==sys_user_id){
						html+=" &nbsp; &nbsp; <a href=javascript:del('"+id+"'); >删除</a>";
					}else{
						html += "&nbsp; &nbsp; <a style='cursor:text'>--</a>";
					}
					return html;
				}
				//编辑 
				function edit(id){
					var url="project/roomInfo/toedit/"+id;
					openTitleLayer("修改房间信息 ",url,900,450);
				}
				//删除
				function del(id){
					//console.log(id);
					var url = "project/roomInfo/delete";
					layer.confirm("您确定删除吗？", {icon: 3}, function(index){
						jQuery.ajax({
							type:"post",
							async:false,
							url:url,
							data:{id:id},
							success:function(data){
								if(data.success){
									window.layer.msg('保存成功！');
									window.gridObj.refreshPage();
									closeLayer();
								}else{
									layer.alert(data.msg,{icon:7});
								}
							}
						});
					});
				}
				//显示详情 
				function detail(obj,id,cName){
					var url = "project/roomInfo/todetail/"+id;
					$(obj).attr('data-title',cName);
					$(obj).attr('_href',url);
					Hui_admin_tab(obj);
				}
				
							
				
			</script>
		</div>
</div>

	

<jsp:include page="../common-field.jsp"></jsp:include>		
</body>
</html>
	
	

